/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Entidades;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Jhon
 */
@Entity
@Table(name = "account", catalog = "taller", schema = "")
@NamedQueries({
    @NamedQuery(name = "Account.findAll", query = "SELECT a FROM Account a"),
    @NamedQuery(name = "Account.findByIdAccount", query = "SELECT a FROM Account a WHERE a.accountPK.idAccount = :idAccount"),
    @NamedQuery(name = "Account.findByType", query = "SELECT a FROM Account a WHERE a.type = :type"),
    @NamedQuery(name = "Account.findByUseridUser", query = "SELECT a FROM Account a WHERE a.accountPK.useridUser = :useridUser")})
public class Account implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected AccountPK accountPK;
    @Basic(optional = false)
    @Column(name = "type", nullable = false, length = 45)
    private String type;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "account")
    private List<Banktx> banktxList;
    @JoinColumn(name = "User_idUser", referencedColumnName = "idUser", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private User user;

    public Account() {
    }

    public Account(AccountPK accountPK) {
        this.accountPK = accountPK;
    }

    public Account(AccountPK accountPK, String type) {
        this.accountPK = accountPK;
        this.type = type;
    }

    public Account(int idAccount, int useridUser) {
        this.accountPK = new AccountPK(idAccount, useridUser);
    }

    public AccountPK getAccountPK() {
        return accountPK;
    }

    public void setAccountPK(AccountPK accountPK) {
        this.accountPK = accountPK;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public List<Banktx> getBanktxList() {
        return banktxList;
    }

    public void setBanktxList(List<Banktx> banktxList) {
        this.banktxList = banktxList;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (accountPK != null ? accountPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Account)) {
            return false;
        }
        Account other = (Account) object;
        if ((this.accountPK == null && other.accountPK != null) || (this.accountPK != null && !this.accountPK.equals(other.accountPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entidades.Account[accountPK=" + accountPK + "]";
    }

}
